package com.csweimei.rentmanagementtreasure.enterprise.viewModel;

import static com.csweimei.rentmanagementtreasure.base.AppConfig.BUNDLE_KEY;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.enterprise.act.EntHouseDetailActivity;
import com.csweimei.rentmanagementtreasure.http.entity.EntScheduleBean;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.customer.CustomerInfoActivity;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class EntScheduleItemVM extends MultiItemViewModel {
    public EntScheduleItemVM(@NonNull BaseViewModel viewModel) {
        super(viewModel);
    }

    public ObservableField<EntScheduleBean.DataDTO.AllListDTO> entity = new ObservableField<>();

    public void setData(EntScheduleBean.DataDTO.AllListDTO bean) {
        entity.set(bean);
    }



    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle;
            switch (entity.get().getType()){
                case "房源跟进":
                    bundle = new Bundle();
                    bundle.putInt(AppConfig.BUNDLE_KEY, Integer.parseInt(entity.get().getHousingID()));
                    viewModel.startActivity(EntHouseDetailActivity.class,bundle);

                    break;
                case "跟进客户":
                    bundle = new Bundle();
                    bundle.putString(BUNDLE_KEY,entity.get().getSid()+"");
                    bundle.putString(AppConfig.BUNDLE_KEY2,"ent");
                    viewModel.startActivity(CustomerInfoActivity.class,bundle);
                    break;
            }

        }
    });


}
